<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{:session('cp.cpsysname')}--商户管理平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="{:config('webconfig.description');}">
    <meta name="keywords" content="{:config('webconfig.keywords');}">
    <meta name="author" content="runoob">
    <link rel="stylesheet" href="__STATIC_URL__/static/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/index.css"/>
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/bootstrap-datetimepicker.css"/>
    <script src="__STATIC_URL__/static/js/jquery-2.1.4.min.js"></script>
    <script src="__STATIC_URL__/static/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="__STATIC_URL__/static/js/commen.js" type="text/javascript" charset="utf-8"></script>
    <script src="__STATIC_URL__/static/js/bootstrap-datetimepicker.js" type="text/javascript" charset="utf-8"></script>
    <style>
        thead tr th{
            text-align: center;
        }
        thead tr th:nth-child(1){
            text-align: left;
        }
        tbody tr td{
            text-align: center;
        }
        tbody tr td:nth-child(1){
            text-align: left;
        }
    </style>
</head>
<body>
{include file='public/header'/}
<section id="content">
    <!------------------导航-------------------------->
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content">
        <div class="page-heading mgl15 mgr15">
            <ol class="breadcrumb">
                <li>当前位置是&nbsp;:</li>
                <li><a href="#">会员卡管理</a></li>
                <li>
                    <a href="javascript:history.back();">会员卡统计</a>
                </li>
                <li class="active" style="color: #02b87f;"> 会员卡核销明细</li>
            </ol>
        </div>
        <div class="panel panel-default panel-search mgl15 mgr15">
            <div class="panel-heading">
                <h3 class="panel-title"><span class="glyphicon glyphicon-search pull-left" style="margin-right: 10px;"></span>筛选</h3>
            </div>
            <div class="panel-body">
                <form action="" method="get" class="form-horizontal table-search form-search" role="form" id="machform">
                    <div class="col-sm-6 col-md-6 col-lg-4 ">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">核销门店：</label>
                            <div class="col-sm-9">
                                <select name="mid" class="form-control">
                                    {if condition="get_mid_num() neq '1'"}
                                    <option value="">请选择门店</option>
                                    {/if}
                                    {volist name='mach' id='mid'}
                                    <option value="{$mid['id']}" {if condition="$p_data['mid'] eq $mid['id']"}selected{/if}>{$mid.merchant}</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6 col-md-6 col-lg-4 ">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">核销员：</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" placeholder="请输入核销员" name="con_username" value="{$p_data['con_username']}">
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6 col-md-6 col-lg-4">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">会员卡号：</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" name="code" placeholder="请输入会员卡号" value="{$p_data['code']}">
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6 col-md-6 col-lg-4">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">核销金额：</label>
                            <div class="col-sm-9">
                                <div class="input-group">
                                    <input name="min_balance" type="text" value="{$p_data['min_balance']}"   placeholder="请输入" class="form-control">
                                    <div class="input-group-addon">至</div>
                                    <input name="max_balance" type="text" value="{$p_data['max_balance']}" class="form-control" placeholder="请输入">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6 col-md-6 col-lg-4">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">时间：</label>
                            <div class="col-sm-9">
                                <div class="input-group">
                                    <input name="starttime" type="text" value=""  readonly="readonly" id="starttime" placeholder="请选择" class="form-control">
                                    <div class="input-group-addon">至</div>
                                    <input name="endtime" type="text" value=""  readonly="readonly" id="endtime" class="form-control" placeholder="请选择">
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="panel-footer">
                <a href="javascript:;" class="btn btn-primary" onclick="searchform()">查找</a>
                <a href="javascript:;" class="btn btn-default" onclick="clearform()">清空</a>
            </div>
        </div>
        <div class="alert alert-success" style="background-color: rgba(204, 228, 223, 0.3);margin: 5px 10px 5px 10px;">
            <strong>
                <i class="ti-info-alt"></i>
            </strong>
            会员卡管理（旧）中，统计显示只到2018-9-1日之前，之后的不再做统计，数据可能会和现用的数据统计及显示有所差异，2018-9-1日起的数据全部以现有的会员卡管理中为准。
        </div>

            <div class="panel panel-default mgl15 mgr15">
                <div class="panel-heading">
                    <h5 class="panel-title">
                        核销分析

                    </h5>
                </div>
                <div class="panel-body">
                    <ul class="fenxilist clearfix">
                        <li class="col-sm-2">
                            <div>核销笔数(日)</div>
                            <div>{$daysum.numsum}</div>
                        </li>
                        <li class="col-sm-2">
                            <div>核销笔数(周)</div>
                            <div>{$weeksum.numsum}</div>
                        </li>
                        <li class="col-sm-2">
                            <div>核销笔数(月)</div>
                            <div>{$monthsum.numsum}</div>
                        </li>
                        <li class="col-sm-2">
                            <div>核销金额(日)</div>
                            <div>{$daysum.del_balsum}</div>
                        </li>
                        <li class="col-sm-2">
                            <div>核销金额(周)</div>
                            <div>{$weeksum.del_balsum}</div>
                        </li>
                        <li class="col-sm-2">
                            <div>核销金额(月)</div>
                            <div>{$monthsum.del_balsum}</div>
                        </li>
                    </ul>
                </div>
            </div>

        <div class="panel mgl15 mgr15" >
            <div class="panel-heading addCharts" style="background:#ededed;">核销明细</div>
            <div class="panel-body">
                <table class="table table-bordered">
                    <thead>
                    <th>编号</th>
                    <th>会员卡名称</th>
                    <th>卡号</th>
                    <th>核销门店</th>
                    <th>核销金额</th>
                    <th>核销员</th>
                    <th>核销方式</th>
                    <th>核销时间</th>
                    </thead>
                    <tbody>
                    {volist name="list" id="vo"}
                    <tr>
                        <td>{$vo.id}</td>
                        <td>
                            {eq name=":getcardtitle($vo['card_id'],1)" value=""}
                            未知
                            {else/}
                            <a href="{:url('cardus/cardinfo',['card_id'=>$vo['card_id']])}" class="btn-link">{$vo.card_id|getcardtitle=###,1}</a>
                            {/eq}
                        </td>
                        <td>{$vo.code}</td>
                        <td>{$vo.mid|getmachnames}</td>

                        <td>{eq name='vo.del_balance' value="0"}{$vo.pay_balance}{else/}{$vo.del_balance}{/eq}</td>
                        <th>{$vo.con_username}</th>
                        <th>
                            {eq name=":is_numeric($vo['hx_fs'])" value="true"}
                            {$vo.source|getcardussource=###}
                            {else/}
                            {$vo.hx_fs}
                            {/eq}
                        </th>
                        <td>{$vo.create_time}</td>
                    </tr>
                    {/volist}
                    </tbody>

                </table>
            </div>
            {$list->render()}
        </div>

        {include file='public/footer'/}
    </div>

</section>
</body>

<script type="text/javascript">
    $(function () {
        var myDate = new Date();
        $('#starttime').datetimepicker({
            minView: "month", //选择日期后，不会再跳转去选择时分秒
            language: 'zh-CN',
            format: 'yyyy-mm-dd',
            todayBtn: 1,
            autoclose: 1,
            todayHighlight: true,
            endDate: new Date()
        }).on('changeDate', function (ev) {
            var starttime = $('#starttime').val();
            var endtime = $('#endtime').val();
            if (starttime != "" && endtime != "") {
                var startD = new Date(Date.parse(starttime.replace(/-/g, "/")));
                var endD = new Date(Date.parse(endtime.replace(/-/g, "/")));
                var days = parseInt((endD.getTime() - startD.getTime()) / (1000 * 60 * 60 * 24));
                if (endtime < starttime) {
                    $('#starttime').val('');
                    alert('结束时间必须大于大于时间');
                    return;
                }
                ;
                $("#endtime").datetimepicker('setStartDate', starttime);
                $("#starttime").datetimepicker('hide');
            }
        });
        $('#endtime').datetimepicker({
            minView: "month", //选择日期后，不会再跳转去选择时分秒
            language: 'zh-CN',
            format: 'yyyy-mm-dd',
            todayBtn: 1,
            autoclose: 1,
            todayHighlight: true,
            endDate:new Date()
        }).on('changeDate', function (ev) {
            var starttime = $('#starttime').val();
            var endtime = $('#endtime').val();
            if (starttime != "" && endtime != "") {
                var startD = new Date(Date.parse(starttime.replace(/-/g, "/")));
                var endD = new Date(Date.parse(endtime.replace(/-/g, "/")));
                var days = parseInt((endD.getTime() - startD.getTime()) / (1000 * 60 * 60 * 24));
                if (endtime < starttime) {
                    $('#endtime').val('');
                    alert('结束时间必须大于开始时间');
                    return;
                }
                $("#starttime").datetimepicker('setEndDate', endtime);
                $("#endttime").datetimepicker('hide');
            }
        });
    });
    //筛选条件
    function filtertj() {
        $("#payform").submit();
    };
    //筛选条件
    function cleartj() {
        $(".form-virtical input").val("");
        $("select").val("");
    };
</script>
</html>
